package com.zzyl.common.utils.ollama;


import com.zzyl.common.utils.ollama.httpUtil.OllamaHttpUtil;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Random;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * ollama初始化类
 */
public class Ollama {

    public void init() {
        Socket socket = new Socket();
        boolean isConnect=false;
        try {
            socket.connect(new InetSocketAddress("192.168.34.203",11434));
            isConnect=true;
        } catch (IOException e) {
            isConnect=false;
        }
        if(!isConnect) {
            throw new RuntimeException("ollama服务未启动");
        }else{
            System.out.println("ollama服务检测正在运行中.");
        }



    }
    String prompt="";
    public void setPrompt(String prompt) {
        this.prompt=prompt;
    }
    public void setModel(String model) {
        OllamaHttpUtil.MODEL=model;
    }

    public String Logic(String body){
        return OllamaHttpUtil.sendGenerator(body,prompt);
    }


}
